# stage.create_grid_overlay(line_separation, "line_color")
stage.create_grid_overlay(50, "grey")
target = codesters.Sprite("triangle", 0, 0)
target.set_opacity(.5)
target.go_to(-200, -150)
target.say("Target")
target.glide_to(100, 150)
sprite = codesters.Sprite("triangle")
sprite.go_to(-200, -150)
sprite.set_speed(1)
sprite.say("Start")
try:
tval1 = sprite.get_x()
except:
tval1 = "DNE"
try:
tval2 = sprite.get_y()
except:
tval2 = "DNE"
try:
tval3 = sprite.get_rotation()
except:
tval3 = "DNE"
try:
tval4 = sprite.get_flip()
except:
tval4 = "DNE"
t1 = TestObjective()
t1.add_success(tval1 == 100 and tval2 == 150, "Great Job!")
if tval1 == 100 and tval2 == 150:
sprite.say(" ")
target.say(" ")
t1.add_failure(tval1 == "DNE", "Did you delete the triangle?")
t1.add_failure(tval1 == -200 and tval2 == -150, "Did you translate the triangle?")
t1.add_failure(tval1 == -200 and tval2 != -150, "Did you try a Translate X command?")
t1.add_failure(tval1 != -200 and tval2 == -150, "Did you try a Translate Y command?")
t1.add_failure(tval1 == 100 and tval2 != 150 and tval1 == -200, "Almost there! Try a Translate y command!")
t1.add_failure(tval1 != 100 and tval2 == 150 and tval2 == -150, "Almost there! Try a Translate x command!")
t1.add_failure(tval1 != 100 , "Not quite, try again!")
t1.add_failure(tval2 != 150 , "Not quite, try again!")
t2 = TestObjective()
t2.add_success(tval3 == 0 or tval3 == "DNE", "Great job!")
t2.add_failure(tval3 > 0 and tval4 == False, "Oops! Did you add a rotation command?")
t3 = TestObjective()
t3.add_success(tval4 == False, "Great job!")
t3.add_failure(tval4 == True, "Oops! Did you use a reflection command?")
tester = TestManager()
tester.display_graphics = False
tester.add_test_list([t3, t2, t1])
tester.run_tests()
tester.display_first_feedback()
-
Run Code
-
Activity Submitted!
Submit Work
-
Next Activity
-
Stop Running Code
-
Show Chart
-
Show Console
-
Reset Code Editor
-
Codesters How To (opens in a new tab)